#include "kdcaudiometadata.h"

#include <kdclib.h>

KDCAudioMetaData::KDCAudioMetaData(	int aId, const QString& aCodec, int aChannelCount, int aSampleRate, int aBitrate, int aLength ) :
	pId( aId ), pChannelCount( aChannelCount ), pSampleRate( aSampleRate ), pBitrate( aBitrate ), pLength( aLength ) 
{
	if ( aCodec == "80" )
		pAudioCodec = KDC::MP2;
	else
		if ( aCodec == "8192" )
			pAudioCodec = KDC::AC3;
	else
		if ( aCodec == "85" )
			pAudioCodec = KDC::MP3;
	else
		if ( aCodec == "8153" )
			pAudioCodec = KDC::DTS;
	else
		pAudioCodec = KDC::OtherAudioCodec;
}

int KDCAudioMetaData::id() const
{
	return pId;
}

KDC::AudioCodec KDCAudioMetaData::codec() const
{
	return pAudioCodec;
}

int KDCAudioMetaData::sampleRate() const
{
	return pSampleRate;
}

int KDCAudioMetaData::bitrate() const
{
	return pBitrate;
}

int KDCAudioMetaData::channelCount() const
{
	return pChannelCount;
}

int KDCAudioMetaData::length() const
{
	return pLength;
}

bool KDCAudioMetaData::isSVCDAudio() const
{
	if ( codec() == KDC::MP2 && sampleRate() == 44100 && isInRange( bitrate(), 32, 384 ) )
		return TRUE;
	else
		return FALSE;
}

bool KDCAudioMetaData::isVCDAudio() const
{
	if ( codec() == KDC::MP2 && sampleRate() == 44100 && bitrate() == 224 )
		return TRUE;
	else
		return FALSE;
}

bool KDCAudioMetaData::isCVDAudio() const
{
	if ( codec() == KDC::MP2 && sampleRate() == 44100 && isInRange( bitrate(), 32, 384 ) )
		return TRUE;
	else
		return FALSE;
}

bool KDCAudioMetaData::isDVDPALAudio() const
{
	if ( ( codec() == KDC::AC3 || codec() == KDC::MP2 ) && sampleRate() == 48000 && isInRange( bitrate(), 32, 1536 ) )
		return TRUE;
	else
		return FALSE;
}

bool KDCAudioMetaData::isDVDNTSCAudio() const
{
	if ( codec() == KDC::AC3 && sampleRate() == 48000 && isInRange( bitrate(), 32, 1536 ) )
		return TRUE;
	else
		return FALSE;
}
